package com.arithmetic.version2;

public class SubstractOperation extends BinaryOperation {

    public SubstractOperation() {
        super();
        this.operator = '-';
    }

    public SubstractOperation(int left, int right) {
        super(left, right, '-');
        // 确保减法结果非负
        if (left < right) {
            this.leftOperand = right;
            this.rightOperand = left;
        }
    }

    @Override
    public int calculate() {
        return leftOperand - rightOperand;
    }

    @Override
    public boolean checkingCalculation(int result) {
        return result == (leftOperand - rightOperand);
    }
}
